#include <string>
#include <iostream>

// 产品接口
class Product{
public:
    virtual ~Product() = default;
    virtual void operation() = 0;
};

// 具体产品A
class ConcreteProductA : public Product{
public:
    void operation() override{
        /* A的实现 */
    }
};

// 具体产品B
class ConcreteProductB : public Product{
    void operation() override{
        /* B的实现 */
    }
};

// 工厂类
class Factory{
public:
    static Product* createProduct(const std::string& type){
        if (type == "A"){
            return new ConcreteProductA();
        }
        if(type == "B"){
            return new ConcreteProductB();
        }
        return nullptr;
    }
};

// 使用示例
// Product* productA = Factory::createProduct("A");
// productA->operation();
// delete productA;

// Product* productB = Factory::createProduct("B");
// productB->operation();
// delete productB;